import org.apache.spark.sql.SQLContext
import org.apache.spark.{SparkConf, SparkContext}
/**
  * @ Auther: o2o-rd-0008
  * @ Date:   2019/10/7 18:10
  * @ Param:  ${PARAM}
  * @ Description: 
  */
object test_address {
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf()
    conf.setAppName(s"${this.getClass.getSimpleName}")
    conf.set("spark.debug.maxToStringFields", "500")
        conf.setMaster("local[*]")
    conf.set("es.nodes", "192.168.1.157")
    conf.set("es.port", "9200")
    conf.set("cluster.name", "O2OElastic")
    conf.set("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
    conf.set("spark.sql.caseSensitive", "true")
    val sc = new SparkContext(conf)
    val sqlContext = new SQLContext(sc)
    sc.setLogLevel("WARN")
    sc.hadoopConfiguration.set("fs.s3a.access.key", "GAO7EO9FWKPJ8WFCQDME")
    sc.hadoopConfiguration.set("fs.s3a.secret.key", "LZ0xaHBSYKHaJ9ECDbX9f7zin79UZkXfGoNapRPL")
    sc.hadoopConfiguration.set("fs.s3a.endpoint", "https://obs.cn-north-1.myhuaweicloud.com")




//    val brandapi_vf = ReadConfig(Map(
//      "spark.mongodb.input.uri" -> "mongodb://ob:O2Odata123!@ 192.168.0.149:27017/admin"
//      , "spark.mongodb.input.database" -> "Address"
//      , "spark.mongodb.input.collection" -> s"tmall_address_2002"))
//    val brandapi_vf_df = sqlContext.read.json(MongoSpark.load(sc, brandapi_vf).map(line => {
//      val nObject = JSON.parseObject(line.toJson())
//      nObject.remove("_id")
//      nObject.toJSONString
//    })).repartition(5).write
//      .json(s"s3a://o2o-dimension-table/address_table/address_source_data_2020/address_platform_newAdd/2020_2/tmall_address_2020_2")

  }
}
